package com.example.tests;

import org.testng.annotations.Test;

import com.example.fw.Contacts;
import static org.testng.AssertJUnit.assertFalse;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Random;


public class ContactRemovalTests extends TestBase {
	
	@Test
	public void testContactCanBeRemoved() throws Exception {
		Contacts oldList = app.getContactHelper().getContacts();
		assertFalse("There are 0 contacts. Nothing to delete!",
				(oldList.size() == 0));
	          	int index = new Random().nextInt(oldList.size());
	          	ContactObject contactToRemove = app.getContactHelper().getContact(index);
	          	app.getContactHelper().deleteContact(index);
	          	Contacts newList = app.getContactHelper().getContacts();
	          	assertThat(newList, equalTo(oldList.without(contactToRemove)));

	}

}
